feat(topo): add standalone basin topo.nc generation pipeline#31
Open
jmichellehu wants to merge 13 commits into
Open
feat(topo): add standalone basin topo.nc generation pipeline#31jmichellehu wants to merge 13 commits into
jmichellehu wants to merge 13 commits into
Conversation
Add four python scripts to construct topo.nc for SMRF/iSnobal using an input basin name, HUC ID, or input polygon file. No dependency on USDA-ARS basin_setup repository. Contains: - generate_topo.py: full pipeline manager (fetch_basin → fetch_dem → build_topo_nc) - fetch_basin.py: queries USGS WBD for HUC watershed boundaries - fetch_dem.py: streams or downloads USGS 3DEP 1/3 arc-second DEM tiles - build_topo_nc.py: combines DEM, basin mask, and vegetation into topo.nc [conda/basin_setup.yaml] update to match the new pipeline. Remove legacy version pins and unused packages (colorama, coloredlogs, inicheck, spatialnc); add requests; relax python and numpy constraints.
There was a problem hiding this comment.
Pull request overview
Adds a self-contained Python pipeline under scripts/topo/ for generating a topo.nc file (DEM, basin mask, vegetation layers) suitable for SMRF/iSnobal, replacing the dependency on the external USDA-ARS basin_setup repository. State flows between scripts via a basin.env key=value file in the output directory, and the existing basin_setup conda environment is restructured to support the new dependencies.
Changes:
- Four new scripts:
generate_topo.pyorchestrator plusfetch_basin.py(USGS WBD HUC fetch),fetch_dem.py(3DEP DEM tiles viavsicurlor download), andbuild_topo_nc.py(CF-compliant NetCDF assembly with LANDFIRE or user-supplied vegetation). - New
scripts/topo/README.mddocumenting requirements, vegetation options, quick start, step-by-step usage, and thebasin.envhandoff contract. conda/basin_setup.yamlrewritten: legacy pins/packages removed (colorama,coloredlogs,inicheck,spatialnc, strictpython=3.11,numpy<1.25,gdal<3.9),requestsanddaskadded, constraints relaxed.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/topo/README.md | Documents new topo pipeline, vegetation options, CLI examples, and basin.env contract |
| scripts/topo/generate_topo.py | Orchestrator chaining basin → DEM → topo.nc with conda-env guard and shared CLI |
| scripts/topo/fetch_basin.py | Queries USGS WBD by HUC ID/name/polygon and writes UTM GeoPackage + basin.env |
| scripts/topo/fetch_dem.py | Queries USGS TNM for 3DEP tiles, streams or downloads them, mosaics via GDAL VRT/Warp |
| scripts/topo/build_topo_nc.py | Clips DEM/vegetation, rasterizes mask, writes CF-style NetCDF with projection var |
| conda/basin_setup.yaml | Replaces legacy env with relaxed deps for the new pure-Python pipeline |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Default uses vsicurl, keeping the flag creates more confusion
Apply Copilot suggestion to guard against issues with malformed tile titles. Co-authored by Claude Sonnet 4.6
SMRF's load_topo.py expects the UTM zone to be stored in projection info. Add handling for hemispheres to extract 2 digit zone.
- Fix -e EPSG override so crs in polygon and basin.env agree
- Validate EPSG is a UTM zone across all scripts
- Enforce crs checks for input POLY
- Mask EVT NoData pixels to deal with extent padding, fill with open (tau=1,k=0)
- Change gdf.crs.srs to f'EPSG:{gdf.crs.to_epsg()}' in _padded_extents
- Add check for zero-sized tiles in fetch_dem
- Fix minor typos in README.md and add Claude acknowledgement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add four python scripts to automate construction of topo.nc for SMRF/iSnobal with input basin name, HUC ID, or polygon. No dependency on USDA-ARS basin_setup repository. Includes associated conda env and README.md.
[scripts/topo] contains:
[conda/basin_setup.yaml] update to match the new pipeline. Remove legacy version pins and unused packages (colorama, coloredlogs, inicheck, spatialnc); add requests; relax python and numpy constraints.